package com.fcscs.cservice.gwt.server;

import java.util.List;

import com.fcscs.core.common.SearchResultsContainer;
import com.fcscs.core.gwt.server.FcsRemoteServiceServlet;
import com.fcscs.core.system.ApplicationContextHolder;
import com.fcscs.core.util.CommonUtil;
import com.fcscs.cservice.domain.model.GuestProfileFindView;
import com.fcscs.cservice.domain.model.GuestProfileView;
import com.fcscs.cservice.gwt.client.GuestProfileService;
import com.fcscs.cservice.service.GuestProfileManager;

@SuppressWarnings("serial")
public class GuestProfileServiceImpl extends FcsRemoteServiceServlet implements GuestProfileService{
	private GuestProfileManager gpMgr = (GuestProfileManager)ApplicationContextHolder.getBeanFromContext("guestProfileManager");

	@Override
	public SearchResultsContainer<GuestProfileFindView> findGuestProfile(String firstName, String lastName, String roomNo, String phoneNo,
			String mobileNo, String memberNo, int start, int resultCnt) {
		Long propId = CommonUtil.getUserContext().getPropertyId();
		List<GuestProfileFindView> gpList = gpMgr.findGuestProfile(propId, firstName, lastName, roomNo, phoneNo, mobileNo, memberNo, start, resultCnt, false);
		int count = gpMgr.findGuestProfileCnt(propId, firstName, lastName, roomNo, phoneNo, mobileNo, memberNo, false);
		return new SearchResultsContainer<GuestProfileFindView>(gpList, count);
	}

	@Override
	public GuestProfileView updateGuestProfileView(GuestProfileView gpView) {
		gpView.setOrgId(CommonUtil.getUserContext().getOrgId());
		gpView.setPropertyId(CommonUtil.getUserContext().getPropertyId());
		return gpMgr.updateGuestProfileView(gpView);
	}

	@Override
	public GuestProfileView getGuestProfileView(long id) {
		return gpMgr.getGuestProfileView(id);
	}
}
